// 通过id连表查询数据库
const {unite} = require("../mysql.js")
const express = require("express")
const unites = express.Router()
unites.post("/uniteApi",(req,res)=>{
    var ids = req.body.id
    console.log(ids);
    let sql = "select * from  comput where id = ?"
    unite(sql,ids).then(result => {
        res.send(result)
    }).catch(err => {
        res.send({
            code:201,
            message:'查询失败'
        })
    });
})

// 查询规格
unites.post("/uniteApiFamily",(req,res)=>{
    var ids = req.body.id
    console.log(ids);
    let sql = "select spec from  comput where family = ?"
    unite(sql,ids).then(result => {
        res.send({
            code:200,
            message:'查询成功',
            data:result
        })
    }).catch(err => {
        res.send({
            code:201,
            message:'查询失败'
        })
    });
})

// 二次按照名称查询规格
unites.post("/uniteApiFamilyGG",(req,res)=>{
    var ids = req.body.spec
    console.log(ids);
    let sql = "select * from  comput where spec = ?"
    unite(sql,ids).then(result => {
        res.send({
            code:200,
            message:'查询成功',
            data:result
        })
    }).catch(err => {
        res.send({
            code:201,
            message:'查询失败'
        })
    });
})

module.exports = {
    unites
}